﻿//using System;
//using System.Configuration;
//using System.Linq;
//using System.Net.Mail;
//using System.Text;

//namespace Hesheng.EAI.Utility.EmailHelper
//{
//    public class MailHelper
//    {
//        /// <summary>
//        /// 返回标题头DIV
//        /// </summary>
//        /// <param name="t"></param>
//        /// <returns></returns>
//        public string GetTitleDiv(string t)
//        {
//            return string.Format("<div><br/><b>{0}</b><br/></div>", t);
//        }

//        /// <summary>
//        /// 发送邮件
//        /// </summary>
//        /// <param name="mailSubject"></param>
//        /// <param name="mailBody"></param>
//        /// <param name="attachment"></param>
//        /// <param name="isRt"></param>
//        /// <param name="isOrder"></param>
//        public void SendMail(string mailSubject, string mailBody, string attachment, bool isRt, bool isOrder)
//        {
//            string sendMailAddress;
//            if (isOrder)
//            {
//                sendMailAddress = ConfigurationManager.AppSettings["SendMailAddress"];
//                if (isRt)
//                    sendMailAddress = ConfigurationManager.AppSettings["RTSendMailAddress"];
//            }
//            else
//            {
//                sendMailAddress = ConfigurationManager.AppSettings["NoOrderSendMailAddress"];
//                if (isRt)
//                    sendMailAddress = ConfigurationManager.AppSettings["RTNoOrderSendMailAddress"];
//            }
//            SendMail(mailSubject, mailBody, attachment, sendMailAddress);
//        }

//        /// <summary>
//        /// 发送邮件
//        /// </summary>
//        /// <param name="mailSubject"></param>
//        /// <param name="mailBody"></param>
//        /// <param name="attachment"></param>
//        /// <param name="sendMailAddress"></param>
//        public void SendMail(string mailSubject, string mailBody, string attachment, string sendMailAddress)
//        {
//            using (var m = new MailMessage())
//            {
//                var fromMailAddress = ConfigurationManager.AppSettings["FromMailAddress"];
//                var fromMailAddressYu = ConfigurationManager.AppSettings["FromMailAddressYu"];
//                var fromMailPwd = ConfigurationManager.AppSettings["FromMailPwd"];
//                var host = ConfigurationManager.AppSettings["Host"];

//                var arrTo = sendMailAddress.Split(';');
//                foreach (var t in arrTo.Where(t => t.Length > 4))
//                {
//                    m.To.Add(new MailAddress(t));
//                }

//                m.From = new MailAddress(fromMailAddress, "Hesheng", Encoding.UTF8);
//                m.Subject = mailSubject;
//                m.Body = mailBody;
//                m.IsBodyHtml = true;

//                m.SubjectEncoding = Encoding.GetEncoding("GB2312");
//                m.BodyEncoding = Encoding.GetEncoding("GB2312");
//                if (attachment.Length > 0)
//                {
//                    m.Attachments.Add(new Attachment(attachment));
//                }

//                using (var sm = new SmtpClient
//                {
//                    Credentials = new System.Net.NetworkCredential(fromMailAddressYu, fromMailPwd),
//                    Host = host,
//                    DeliveryMethod = SmtpDeliveryMethod.Network
//                })
//                {
//                    sm.Send(m);

//                }
//            }
//        }

//        public void SendMailNoException(string mailSubject, string mailBody, string mailAddrs)
//        {
//            try { SendMail(mailSubject, mailBody, String.Empty, true, true); }
//            catch { }
//        }
//        /// <summary>
//        /// 获取表格开头
//        /// </summary>
//        /// <param name="sb"></param>
//        public string GetHead()
//        {
//            return "<table border=\"1\" style=\"border-collapse:collapse\">";
//        }

//        /// <summary>
//        /// 获取行
//        /// </summary>
//        /// <param name="str"></param>
//        public string GetHtmlRow(string str)
//        {
//            return string.Format("<tr>{0}</tr>", str);
//        }

//        /// <summary>
//        /// 获取列
//        /// </summary>
//        /// <param name="str"></param>
//        public string GetHtmlCol(string str)
//        {
//            return string.Format("<td>{0}</td>", str);
//        }
//        /// <summary>
//        /// 获取表格结尾
//        /// </summary>
//        /// <param name="sb"></param>
//        public string GetEnd()
//        {
//            return "</table>";
//        }
//    }
//}
